package com.hnas.trade.domain;

import com.hnas.common.domain.CoreTradeType;
import com.hnas.core.util.StringUtil;

public enum OrderType {

	BuyGasolineVip("01","0","购买加油vip"),
	BuyGasoline("02","0","加油"),
	Recharge("03","1","充值"),
	ScanCodePayment("04","0","用户扫码支付"),
	Transfer_In("05","1","转账-转入"),
	Transfer_Out("06","0","转账-转出"),
	ThreeCharge("07","0","三冲充值"),
	LinkNetTrade("08","0","联机交易"),
	LinkNetTrade_Proxy("09","0","代理联机交易"),
	Reject("10","0","退货"),
	Cancel("11","0","撤销"),
	CZ("12","0","冲正"),
	TJJY("13","0","脱机交易"),
	TKLinkNetTrade("14","0","贴卡联机交易"),
	TKCZ("15","1","贴卡充值"),
	DZKGK("16","0","电子卡购卡"),
	STKGK("17","0","实体卡卡购卡"),
	GMSP("18","0","礼品券购买");
	
	private String type;
	private String parentType;
	private String description;

	private OrderType(String type, String parentType, String description) {
		this.type = type;
		this.parentType = parentType;
		this.description = description;
	}

	public String getParentType() {
		return parentType;
	}

	public void setParentType(String parentType) {
		this.parentType = parentType;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public static String getOrderTypeName(String type){
		if(StringUtil.isEmpty(type)) return null;
		for(OrderType ot : OrderType.values()){
			if(ot.type.equals(type)){
				return ot.getDescription();
			}
		}
		return null;
	}
	
	public static OrderType getOrderType(String orderType){
		if(StringUtil.isEmpty(orderType)) return null;
		for(OrderType ot : OrderType.values()){
			if(ot.type.equals(orderType)){
				return ot;
			}
		}
		return null;
	}
	
	
	
	/**
	 * 根据核心交易大类小类获取订单类型
	 * @param tradeType
	 * @param subTradeType
	 * @return
	 */
	public static OrderType getByCore(String tradeType,String subTradeType){
		
		//充值
		if(CoreTradeType.Recharge_ZC.getType().equals(tradeType) && 
				CoreTradeType.Recharge_ZC.getSubType().equals(subTradeType)){//充值
			return Recharge;
		}
		if(CoreTradeType.Recharge_YY.getType().equals(tradeType) && 
				CoreTradeType.Recharge_YY.getSubType().equals(subTradeType)){//运营充值
			return Recharge;
		}
		if(CoreTradeType.Recharge_CZZS.getType().equals(tradeType) && 
				CoreTradeType.Recharge_CZZS.getSubType().equals(subTradeType)){//充值赠送
			return Recharge;
		}
		
		//联机交易
		if(CoreTradeType.LinkNetTrade.getType().equals(tradeType) && 
				CoreTradeType.LinkNetTrade.getSubType().equals(subTradeType)){//联机交易
			return LinkNetTrade;
		}
	
		
		//代理联机交易
		if(CoreTradeType.LinkNetTrade_Proxy.getType().equals(tradeType) && 
				CoreTradeType.LinkNetTrade_Proxy.getSubType().equals(subTradeType)){//代理联机交易
			return LinkNetTrade_Proxy;
		}
		
		//转入
		if(CoreTradeType.Transfer_In.getType().equals(tradeType) && 
				CoreTradeType.Transfer_In.getSubType().equals(subTradeType)){//联机户转领款户-转入
			return Transfer_In;
		}
		//转出
		if(CoreTradeType.Transfer_Out.getType().equals(tradeType) && 
				CoreTradeType.Transfer_Out.getSubType().equals(subTradeType)){//联机户转领款户-转出
			return Transfer_Out;
		}
		
		//冲正
		if(CoreTradeType.LinkNetTrade_CZ.getType().equals(tradeType) && 
				CoreTradeType.LinkNetTrade_CZ.getSubType().equals(subTradeType)){//充值赠送
			return CZ;
		}
		if(CoreTradeType.Recharge_CZZSCZ.getType().equals(tradeType) && 
				CoreTradeType.Recharge_CZZSCZ.getSubType().equals(subTradeType)){//充值赠送
			return CZ;
		}
		
		//撤销
		if(CoreTradeType.LinkNetTrade_Cancel.getType().equals(tradeType) && 
				CoreTradeType.LinkNetTrade_Cancel.getSubType().equals(subTradeType)){//充值赠送
			return Cancel;
		}
		
		//退货
		if(CoreTradeType.LinkNetTrade_Reject.getType().equals(tradeType) && 
				CoreTradeType.LinkNetTrade_Reject.getSubType().equals(subTradeType)){//充值赠送
			return Reject;
		}
		return null;
	}
	
	public static void main(String[] args) {
		OrderType type = getByCore("38", "00");
		if(null!=type){
			System.out.println(type.getDescription());
		}else{
			System.out.println("微克");
		}
	}
}
